<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="pits.dto.AdminCourseListDTO" %>
<%@ page import="pits.dao.AdminCourseListDAO" %>
<%@ page import="java.util.List" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>

<portlet:defineObjects />

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script type="text/javascript">
	function getForm(namespace, name) {
		return document.forms[namespace + name];
	}
 
	function submitForm(namespace, name, action) {
		var frm = getForm(namespace, name);
		frm.txtAction.value = action;
		frm.submitLink.value = "AdminCourseList.jsp";
		frm.submit();
	}
</script>

</head>

<body>
<form name="<portlet:namespace/>myForm" action="<portlet:actionURL/>" method="POST">
<input type="hidden" name="txtAction"/>
<input type="hidden" name="submitLink"/>
<p align="right">
	You are logging in as 
	<a href="#" onclick="submitForm('<portlet:namespace/>', 'myForm', 'getEmployeeInfo')"><b>${sessionScope.userName}</b></a>
	! &nbsp;
	<a href="#" onclick="submitForm('<portlet:namespace/>', 'myForm', 'home')">Home</a>
	| &nbsp;
	<a href="#" onclick="submitForm('<portlet:namespace/>', 'myForm', 'logout')">Logout</a>
</p>
</form>
<form name="<portlet:namespace/>courseListForm" action="<portlet:actionURL/>" method="post">
<input type="hidden" name="txtAction" />
<input type="hidden" name="submitLink" />
<input type="hidden" name="courseID" />
<table>
	<tr>
		<td>
			<table border="1" width="100%">
				<tr align="center" valign="middle">
					<td rowspan="2">&nbsp;Check&nbsp;</td>
					<td rowspan="2">&nbsp;Name&nbsp;</td>
					<td rowspan="2">&nbsp;Department/Institute Issued&nbsp;</td>
					<td rowspan="2">&nbsp;Period (day)&nbsp;</td>
					<td rowspan="2">&nbsp;Description&nbsp;</td>
					<td colspan="3">&nbsp;Technology&nbsp;</td>
					<td rowspan="2">&nbsp;Date issued&nbsp;</td>
				</tr>
				<tr align="center" valign="middle">
					<td>Language</td>
					<td>Framework/Technology</td>
					<td>DBMS</td>
				</tr>
				
				<%
				List<AdminCourseListDTO> courseList = new AdminCourseListDAO().getData();
				for (int i = 0; i < courseList.size(); i++) {
				%>
				<tr>
					<td align="center">
						<label><input type="checkbox" name="checkbox" value="checkbox" /></label>
					</td>
					<td align="left" valign="middle">
						<a href="#" onclick="
							document.forms['<portlet:namespace/>courseListForm'].courseID.value = '' + <%=courseList.get(i).getCourseID() %>;
							submitForm('<portlet:namespace/>', 'courseListForm', 'editCourseInfo');
						">
							<%=courseList.get(i).getName() %>
						</a>
					</td>
					<td align="left" align="center" valign="middle"><%=courseList.get(i).getDepartName() %></td>
					<td align="left" valign="middle"><%=courseList.get(i).getPeriod() %></td>
					<td align="left" valign="middle"><%=courseList.get(i).getDescription() %></td>
					<td align="center" valign="middle"><%=courseList.get(i).getLanguage() %></td>
					<td align="center" valign="middle"><%=courseList.get(i).getFrameTech() %></td>
					<td align="center" valign="middle"><%=courseList.get(i).getDBMS() %></td>
					<td align="left" valign="middle"><%=courseList.get(i).getDateIssused() %></td>
				</tr>
				<%}%>
				
			</table>
		</td>
	</tr>
</table>
</form>
</body>
</html>